<!--
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-05-27 08:43:07
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-07-11 09:24:16
 * @FilePath: \linePatrol\vue-element-plus-admin\src\views\Authorization\User\components\Detail.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script setup lang="tsx">
import { PropType } from 'vue'
import { DepartmentUserItem } from '@/api/department/types'
import { Descriptions, DescriptionsSchema } from '@/components/Descriptions'
import { ElImage } from 'element-plus'
const PATH_URL = import.meta.env.VITE_API_PHOTO_PATH

const props = defineProps({
  currentRow: {
    type: Object as PropType<DepartmentUserItem>,
    default: () => undefined
  },
  detailSchema: {
    type: Array as PropType<DescriptionsSchema[]>,
    default: () => []
  },
  UserDetail: {
    type: Object as PropType<any>,
    default: () => undefined
  }
})
const NewCurrentRow: any = [
  {
    field: 'roleIds',
    label: '角色',
    slots: {
      default: (data: any) => {
        return data.roleIds.map((item) => {
          const i = props.UserDetail.roles.filter((res) => {
            return res.roleId == item
          })
          return `${i[0].roleName}     `
        })
      }
    }
  },
  {
    field: 'postIds',
    label: '岗位',
    slots: {
      default: (data: any) => {
        if (data.postIds && data.postIds.length !== 0) {
          return data.postIds.map((item) => {
            const i = props.UserDetail.posts.filter((res) => {
              return res.postId == item
            })
            return `${i[0].postName}     `
          })
        }
      }
    }
  },
  {
    field: 'avatar',
    label: '头像',
    slots: {
      default: (data: any) => {
        return (
          <ElImage
            style="width: auto; height: 70px;margin-left:10px"
            src={PATH_URL + data.avatar}
            preview-src-list={[PATH_URL + data.avatar]}
            fit="cover"
          ></ElImage>
        )
      }
    }
  }
]
const Data = [...props.detailSchema, ...NewCurrentRow]
// console.log(props.currentRow);
</script>

<template>
  <Descriptions :schema="Data" :data="currentRow || {}" />
</template>
